home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / AVIAudioOutput.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  2.0 KB  |  77 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_AVIAUDIOOUTPUT_H
  19. #define f_AVIAUDIOOUTPUT_H
  20.  
  21. #include <windows.h>
  22.  
  23. class AVIAudioOutputBuffer {
  24. public:
  25.     AVIAudioOutputBuffer *next,*prev;
  26.     WAVEHDR hdr;
  27.     DWORD dwBytesInBuffer;
  28.  
  29.     AVIAudioOutputBuffer(long bsize);
  30.     ~AVIAudioOutputBuffer();
  31.     BOOL init(HWAVEOUT hWaveOut);
  32.     BOOL post(HWAVEOUT hWaveOut);
  33.     void deinit(HWAVEOUT hWaveOut);
  34. };
  35.  
  36. class AVIAudioOutput {
  37. private:
  38.     AVIAudioOutputBuffer *pending, *pending_tail, *active;
  39.     long bufsize;
  40.     int numbufs, maxbufs;
  41.     HWAVEOUT hWaveOut;
  42.     HANDLE hEventBuffersFree;
  43.     char fill_byte;
  44.     DWORD nSamplesPerSec;
  45.     DWORD nAvgBytesPerSec;
  46.     int iBuffersActive;
  47.     long lAvailSpace;
  48.  
  49.     enum {
  50.         STATE_NONE        = 0,
  51.         STATE_OPENED    = 1,
  52.         STATE_PLAYING    = 2,
  53.         STATE_SILENT    = 10,
  54.     } curState;
  55.  
  56.     BOOL postBuffer(AVIAudioOutputBuffer *aaob);
  57. public:
  58.     AVIAudioOutput(long bufsize, int maxbufs);
  59.     ~AVIAudioOutput();
  60.  
  61.     BOOL init(WAVEFORMATEX *wf);
  62.     void go_silent();
  63.     BOOL isSilent();
  64.     BOOL start();
  65.     BOOL checkBuffers();
  66.     BOOL waitBuffers(DWORD timeout);
  67.     long avail();
  68.     BOOL write(void *data, long len, DWORD timeout);
  69.     BOOL stop();
  70.     BOOL finalize(DWORD timeout);
  71.     void flush();
  72.     long position();
  73.     bool isFrozen();
  74. };
  75.  
  76. #endif
  77.